package com.shiikong_memory.yez;

import love.forte.simbot.spring.EnableSimbot;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import com.shiikong_memory.yez.Tool.FreeMarkerUtil;

import java.io.File;
import java.io.IOException;

@EnableSimbot
@SpringBootApplication
@EnableScheduling
@MapperScan
public class YeZApplication {

    public static void main(String[] args) {
        File file = new File("./config");
        File file1 = new File("./config/application.properties");
        File file2 = new File("./config/YeZ.bot.json");
        File file3 = new File("./config/application.yml");
        //创建配置文件夹和配置文件
        if (!file.exists()){
            file.mkdirs();
        }
        try {
            if (!file1.exists()) FreeMarkerUtil.copyFileFromJar("application.properties", "./config/application.properties");
            if (!file2.exists()) FreeMarkerUtil.copyFileFromJar("simbot-bots/YeZ.bot.json", "./config/YeZ.bot.json");
            if (!file3.exists()) FreeMarkerUtil.copyFileFromJar("application.yml", "./config/application.yml");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        SpringApplication.run(YeZApplication.class, args);
    }

}
